@extends('admin.master')

@section('top')
	<span class="top-title pull-left">我的通用订单</span>
@endsection

@section('content')
<div class="section-search mb10">
	{!! Form::open(['method'=>'get', 'class'=>'form-inline']) !!}
	<input type="hidden" name="type" value="{{ $request->input('type') }}">
	@if ($request->has('status'))
	<input type="hidden" name="status" value="{{ $request->input('status') }}">
	@endif
	<div class="form-group">
		{!! Form::text('word', null, ['class'=>'form-control len wd-search', 'id'=>'kw', 'placeholder'=>'客户名称或域名']) !!}
	</div>
	<div class="form-group">
		<label class="control-label">类型：</label>
		{!! Form::select('product', ['全部类型'] + config('system.product')[2], null, ['class'=>'form-control']) !!}
	</div>
	<button type="submit" class="btn btn-default">查询</button>
{!! Form::close() !!}
</div>
<div class="section-tab mb10">
	<ul class="nav nav-tabs">
		<li @if (!$request->has('status')) class="active" @endif>
			<a href="{{ url('admin/order/myorder?type=2') }}">
			所有订单
			<i class="p-count">({{ $counts->sum() }})</i>
			</a>
		</li>
	@foreach($system['order_status'] as $key=>$value)
		<li @if ($request->input('status') == $key) class="active" @endif>
			<a href="{{ url('admin/order/myorder?type=2&status='.$key) }}">
				{{ $value }}
				<i class="p-count">({{ $counts->get($key, 0) }})</i>
			</a>
		</li>
	@endforeach
	</ul>
</div>
<div class="gridSection">
{!! Form::open(['url'=>'admin/order']) !!}
	<table class="table table-hover table-list order-tb">
		<thead>
			<tr>
				<th width="60" class="text-center">ID</th>
				<th>提单时间</th>
				<th>到期时间</th>
				<th>客户名称</th>
				<th>订单类型</th>
				<th>产品明细</th>
				<th class="text-center">年限</th>
				<th>业务员</th>
				<th>签单金额</th>
				<th>尾款</th>
				<th>网站进度</th>
				<th>评论</th>
				<th class="text-right">操作</th>
			</tr>
		</thead>
		<tbody>
			@if (!$data->isEmpty())
				@foreach ($data as $value)
					<tr>
						<td class="text-center">{{ $value->id }}</td>
						<td>{{ $value->created_at->format('Y-m-d') }}</td>
						<td>{{ $value->expired_at->format('Y-m-d') }}</td>
						<td>
						{{ $value->customer->name }}
						@if ($value->expedited)
							<span class="label label-warning">加急</span>
						@endif
						</td>
						<td>
							<span class="label label-info">{{ $system['product'][$value->type][$value->product] or '' }}</span>
						</td>
						<td>{{ $value->product_detail }}</td>
						<td class="text-center">{{ $value->year }}</td>
						<td>{{ $value->saler->name or '' }}</td>
						<td><span class="text-success">{{ (int)$value->amount }}</span></td>
						<td>
							@if ($value->tail_amount > 0)
								<span class="text-danger">{{ (int)$value->tail_amount }}</span>
							@else
								<span class="text-muted">/</span>
							@endif
						</td>
						<td>
						<span class="text-success">
							{{ $system['order_status'][$value->status] }}
						</span></td>
						<td><span class="label label-warning">{{ $value->replies->count() }}</span></td>
						<td class="text-right">
							<div class="toolbar">
								<a href="{{ route('admin.order.show', $value->id) }}" class="btn-link">详情</a>
								<span class="text-explode ">|</span>
								<a href="{{ route('admin.order.edit', $value->id) }}" class="btn-link">修改</a>
								<span class="text-explode ">|</span>
								<a href="javascript:void(0);" data-id="{{ $value->id }}" class="btn-link delete-item">删除</a>
							</div>
						</td>
					</tr>
				@endforeach
			@endif
		</tbody>
	</table>
	@if (!$data->isEmpty())
	<table class="table table-footer">
		<tfoot>
			<tr>
				<td>
					<div class="pagination-box">
						<div class="pull-right">
							<div class="pagination-info">共有{{ $data->total() }}条， 每页显示：20条</div>
							{!! $data->appends(request()->except('page'))->render() !!}
						</div>
					</div>				
				</td>
			</tr>
		</tfoot>
	</table>
	@else
	<div class="simple-none-data text-center">
		<i class="fa fa-exclamation-circle text-size-20 text-muted" style="vertical-align: middle"></i> 
		<span class="text-size-14 inline-block ml5">没有查询到符合条件的记录</span>
	</div>
	@endif
{!! Form::close() !!}
</div>
@endsection

@section('foot')
	<script type="text/javascript">
	</script>	
@endsection